<template>
	<view class="content">
		<template v-for="(item,index) in commentList">
			
			<view class="itemContent">
				<!-- 昵称 -->
				<text class="name">{{item.name}}</text>
				
				<template v-if="item.is_reply == true">
					<text>回复</text>
					<text class="name">{{item.reply_name}}</text>
				</template>
				
				<!-- 评论 -->
				<text>{{'：' + item.content}}</text>
			</view>
			
		</template>
		
		<view class="all-comment" v-if="maxCount>2">{{'查看全部' + this.maxCount + '条评论'}}</view>
		
	</view>
</template>

<script>
	export default {
		name:"circle-list-comment",
		props: {
			list: {
				type: Array,
				default () {
					return []
				}
			},
		},
		mounted() {
			
			this.maxCount = this.list.length;
			
			if(this.list.length > 2){
				
				this.commentList = this.list.slice(0,2);
				
			}else{
				
				this.commentList = this.list;
			}
			
			// this.commentList = this.list;
		},
		data() {
			return {
				// 只显示两条
				commentList: [],
				maxCount:0
			};
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		background-color: #F2F2F2;
		border-radius: 16rpx;
		padding: 20rpx;
		height: auto;
	}
	.itemContent{
		padding: 4rpx 0;
	}
	.name{
		color: #2B85E4;
	}
	.all-comment{
		margin-top: 10rpx;
		color: #999;
	}
</style>
